//
//  UIBarButtonItem+SPExtension.m
//  Sport
//
//  Created by Cass on 2017/11/8.
//  Copyright © 2017年 Cass. All rights reserved.
//

#import "UIBarButtonItem+SPExtension.h"

@implementation UIBarButtonItem (SPExtension)
+ (instancetype)itemWithImage:(NSString *)normalImage selectedImage:(NSString *)selectedImage title:(NSString *)title target:(id)target action:(SEL)action{
    SPHorizontalButton *button = [SPHorizontalButton buttonWithType:UIButtonTypeCustom];
    [button sizeToFit];
    [[button titleLabel] setLineBreakMode:NSLineBreakByClipping];
    [button setImage:[UIImage imageNamed:normalImage] forState:UIControlStateNormal];
    [button setImage:[UIImage imageNamed:selectedImage] forState:UIControlStateSelected];
    [button setTitle:title forState:UIControlStateNormal];
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    [[button titleLabel] setFont:[UIFont systemFontOfSize:14]];
    [button setTintColor:[UIColor yellowColor]];
    [button sizeToFit];
    return [[UIBarButtonItem alloc]initWithCustomView:button];
}

@end
